package com.listeningframework.boot.autoconfigure.orm.mybatis.support;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.listeningframework.boot.commons.utils.DateFormatUtils;

import java.util.Date;

/**
 * 
 * MyBatis Base Entity
 *
 * @author lixining
 * @version $Id: MybatisBaseEntity.java, v 0.1 2015年7月25日 下午4:46:54 lixining Exp $
 */
public class ListeningMybatisEntity<T> {
    /**
     * 主键ID
     */
    private T        id;
    /**
     * 创建人
     */
    protected String createdBy;
    /**
     * 创建日期
     */
    @JsonIgnore
    protected Date   createdDate;
    /**
     * 更新人
     */
    protected String updatedBy;
    /**
     * 更新日期
     */
    @JsonIgnore
    protected Date   updatedDate;

    /**
     * Getter method for property <tt>id</tt>.
     * 
     * @return property value of id
     */
    public T getId() {
        return id;
    }

    /**
     * Setter method for property <tt>id</tt>.
     * 
     * @param id value to be assigned to property id
     */
    public void setId(T id) {
        this.id = id;
    }

    /**
     * Getter method for property <tt>createdBy</tt>.
     * 
     * @return property value of createdBy
     */
    public String getCreatedBy() {
        return createdBy;
    }

    /**
     * Setter method for property <tt>createdBy</tt>.
     * 
     * @param createdBy value to be assigned to property createdBy
     */
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    /**
     * Getter method for property <tt>createdDate</tt>.
     * 
     * @return property value of createdDate
     */
    public Date getCreatedDate() {
        return createdDate;
    }

    /**
     * Setter method for property <tt>createdDate</tt>.
     * 
     * @param createdDate value to be assigned to property createdDate
     */
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    /**
     * Getter method for property <tt>updatedBy</tt>.
     * 
     * @return property value of updatedBy
     */
    public String getUpdatedBy() {
        return updatedBy;
    }

    /**
     * Setter method for property <tt>updatedBy</tt>.
     * 
     * @param updatedBy value to be assigned to property updatedBy
     */
    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    /**
     * Getter method for property <tt>updatedDate</tt>.
     * 
     * @return property value of updatedDate
     */
    public Date getUpdatedDate() {
        return updatedDate;
    }

    /**
     * Setter method for property <tt>updatedDate</tt>.
     * 
     * @param updatedDate value to be assigned to property updatedDate
     */
    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getCreatedDateString() {
        return DateFormatUtils.datetime2string(createdDate);
    }

    public String getUpdatedDateString() {
        return DateFormatUtils.datetime2string(updatedDate);
    }

    public void setOperatorInfo(String operator) {
        setCreatedBy(operator);
        setUpdatedBy(operator);
    }

}
